<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/themes/bootstrap/easyui.css" />
<link type="text/css"
	href="${pageContext.request.contextPath}/themes/icon.css"
	rel="stylesheet">
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery-1.9.1.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/easyui-lang-zh_CN.js"></script>
</head>
<script type="text/javascript">
$(function(){
	
	$('#dg').datagrid({    
	    url:'Account',    
	    columns:[[    
	        {field:'aId',title:'收支号',width:100,hidden:true},    
	        {field:'oId',title:'订单号',width:100},    
	        {field:'oClassName',title:'订单类别名',width:100}, 
	        {field:'oClassType',title:'收支类型',width:100},
	        {field:'oClassTypeID',title:'类型代号',width:100,hidden:true}, 
	        {field:'oMoney',title:'金额',width:100}, 
	        {field:'oTime',title:'时间',width:150}, 
	        {field:'eId',title:'经手人ID',width:100,hidden:true}, 
	        {field:'eName',title:'经手人姓名',width:100,align:'right'}    
	    ]],    
	    //工具栏位
	    toolbar: [{
			text:'开始时间<input id="begindt" type="text" style="width: 160px">',			
		},'-',{
			text:'结束时间<input id="enddt" type="text" style="width: 160px">',		
		},'-',{
			//查找
			iconCls: 'icon-search',
			text:'查找',
			handler: function(){		
				var sear = $('#search').val();
				var bdt = $('#begindt').combo('getText');
				var edt = $('#enddt').combo('getText');
				if(bdt<=edt){	
					$('#dg').datagrid({
						url:'SearchAccount',
						  columns:[[    
						        {field:'aId',title:'收支号',width:100,hidden:true},    
						        {field:'oId',title:'订单号',width:100},    
						        {field:'oClassName',title:'订单类别名',width:100}, 
						        {field:'oClassType',title:'收支类型',width:100},
						        {field:'oClassTypeID',title:'类型代号',width:100,hidden:true}, 
						        {field:'oMoney',title:'金额',width:100}, 
						        {field:'oTime',title:'时间',width:150}, 
						        {field:'eId',title:'经手人ID',width:100,hidden:true}, 
						        {field:'eName',title:'经手人姓名',width:100,align:'right'}  	       	        
						    ]],						
						queryParams:{"search":sear,"begindt":bdt,"enddt":edt},					
					})
				
					$('#begindt').datetimebox({    
					    showSeconds: true   	 
					});  
					$('#enddt').datetimebox({   
					    showSeconds: true   	    
					});  
				}else{
					$.messager.alert('提示','结束时间不能早于开始时间');  
				}
			}
		},{			
			text:'<input type="text" style="width:150px" id="search" name="search">',
			disabled:true
		}],
	    pagination:true,
	    pageList:[5,10,20,30,50,100,200],
	    rownumbers:true,
	    //盈利统计
	    onLoadSuccess:function(){
	    	var money = 0;
	    	var data = $('#dg').datagrid('getData').rows;
	    	$.each(data,function(i,n){
	    		if(n.oClassTypeID==1){
	    			money += n.oMoney;
	    		}else{
	    			money -= n.oMoney;
	    		}
	    	})	    	
	    	$('#money').numberbox('setValue',money);		
	    },				
					
	    //查询订单详情
	  	onClickCell:function(index, field, value){	  	  	
  			if(field == 'oId'){
  				if ($('#tab').tabs('exists', '订单'+value)) {  					
					$('#tab').tabs('select', '订单'+value);
				} else {					
  					$('#tab').tabs('add', {  						
						title :'订单'+value,
						content :"<iframe  frameborder='no' width='100%' height='100%' src= /superMarketManagementSystem/function/ordermanagement/tradeinformation/orderInfo.jsp></iframe>",						
						closable : true,					
					});
  					$.ajax({
  						url:'getordertab',
  						data:{'oId':value},
  						type:'post'
  					})
				}
  			}
  		}
	}); 
	$('#begindt').datetimebox({    
	    showSeconds: true   	 
	});  
	$('#enddt').datetimebox({   
	    showSeconds: true   	    
	});  
	
})
</script>
<body>
	<table id="dg"></table>  
		<p style="font-size: 12px">提示：1.单击订单号显示订单详情<br/>
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2.查询对话框不输入内容查询为显示所有信息<br/> 
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3.开始时间默认为当日 00:00:00;结束时间默认为当前时间</p>	
		<br/><div style="margin-left: 20px;margin-bottom: 20px">
		盈利总计<input type="text" class="easyui-numberbox" data-options="precision:2" id="money" style="width: 100px">
		</div>
	<div id="tab" class="easyui-tabs" data-options="fit:true"></div>

</body>
</html>